//
//  CMTool.swift
//  covermedia
//
//  Created by limao on 16/6/23.
//  Copyright © 2016年 covermedia. All rights reserved.
//

import UIKit
import Device
typealias StoryBoard = UIStoryboard

public struct CMTool {
    public static let screenWidth = UIScreen.main.bounds.size.width
    public static let screenHeight = UIScreen.main.bounds.size.height
    
    public static let width = UIScreen.main.bounds.size.width
    public static let height = UIScreen.main.bounds.size.height
    
    public static let iOS8: Bool = {
        let os = ProcessInfo().operatingSystemVersion
        
        switch (os.majorVersion,os.minorVersion, os.patchVersion) {
        case (8,_,_):
            return true
        default:
            return false
        }
    }()
    
    public static let sb = UIStoryboard.init(name: "Main", bundle: nil)
    
    public static let isLessEqualIphone5s: Bool = {
        if CMTool.screenWidth <= 321 { return true}
        return false
    }()
    
    public static let iphone4Series: Bool = {
        if CMTool.screenWidth == 320 && CMTool.screenHeight == 480 {
            return true
        }
        return false
    }()
    
    public static let iPhone5Series: Bool = {
        if CMTool.screenWidth == 320 && CMTool.screenHeight == 568 {
            return true
        }
        return false
    }()
    
    
    public static let iPhone5sBelow: Bool = {
        if Device.isSmallerThanScreenSize(.screen4_7Inch) {
            return true
        }
        return false
    }()

    
    public static let screen4_7: Bool = {
        return Device.isEqualToScreenSize(.screen4_7Inch) ? true : false
    }()
    
    public static let screen4: Bool = {
        if Device.isSmallerThanScreenSize(.screen4_7Inch) {
            return true
        }
        return false
    }()
    
    
    public static func pointFor(_ Inch4: CGFloat, Inch4_7: CGFloat, Inch5: CGFloat) -> CGFloat {
        if Device.isSmallerThanScreenSize(.screen4_7Inch) {
            return Inch4
        } else if Device.isEqualToScreenSize(.screen4_7Inch) {
            return Inch4_7
        } else {
            return Inch5
        }
    }
//    static let screen5
    

    
}

public extension Int {
    public var adaptive: CGFloat {
        return CMTool.isLessEqualIphone5s ? CGFloat(Double(self) * 0.8) : CGFloat(self)
    }
}
